package com.open.harmony.business.mapper;

import com.open.harmony.business.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Select("select user_id, user_name, user_account, user_img, user_level from user " +
            "where user_account=#{userAccount} and user_Password=#{userPassword}")
    User login(String userAccount, String userPassword);

    @Select("select count(*) from user where user_account = #{userAccount}")
    Integer findUserAccount(String userAccount);

    @Select("select count(*) from user where user_name = #{userName}")
    Integer findUserName(String userName);

    @Update("UPDATE user SET user_img = #{userImg} WHERE user_id = #{userId}")
    Integer updateImg(Integer userId, String userImg);

    @Insert("INSERT INTO user (user_account, user_password, user_name, user_status, user_level) " +
            "VALUES (#{userAccount}, #{userPassword}, #{userName}, 0, 0)")
    Integer register(User user);

}
